<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>

<html>
<head>

    <%--移动设备优先--%>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"/>

    <%--公共css样式--%>
    <%--<link rel="icon" href="/static/images/party/img/icon-f2-on.png">--%>
    <link type="text/css" rel="stylesheet" href="/static/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="/static/webjars/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="/static/webjars/layui/css/admin.css"/>

    <%--公共js文件--%>
    <script type="application/javascript" src="/static/js/common.js"></script>
    <script type="application/javascript" src="/static/js/jquery.min.js"></script>


    <%--引进layui框架--%>
    <script type="application/javascript" src="/static/webjars/layui/layui.all.js"></script>

    <%--引入echarts框架--%>
    <script type="application/javascript" src="/static/webjars/echarts/echarts.js"></script>
    <title>${pageTitle}</title>
</head>
<body>



<div class="layui-fluid">
    <div class="layui-card">

        <div class="layui-card-header " style="color:#d02e25;font-family: '楷体'; ">
            权限管理
        </div>

        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item refresh-nav" align="center" style="font-family: '宋体'; font-size: 20px;" >
                <div class="layui-inline">
                    <label class="layui-form-label" >身份证号</label>
                    <div class="layui-input-inline">
                        <input style="height: auto;margin-top: 5px" type="text" id="groupName" name="idCard" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">用户ID</label>
                    <div class="layui-input-inline">
                        <input style="height: auto;margin-top: 5px" type="text" id="groupNum" name="userId" placeholder="请输入" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline" id="search">
                    <button class="layui-btn" id="searchBtn" data-type="reload">搜索</button>
                </div>
            </div>
            <div class="layui-card-body">
                <table id="groupList" lay-filter="groupList">

                </table>
            </div>
        </div>
    </div>
</div>







<%-- 查看详情--%>
<div class="layui-hide" id="show-detail">
    <div class="layui-row layui-card-body">
        <div align="center">




        </div>
    </div>
</div>


<script>


    layui.use(['table','form'], function(){
        var table = layui.table
            ,form = layui.form;

        //组织人员列表
        table.render({
            elem: '#groupList'
            // ,height: 'full-200'
            ,method: 'post'
            ,url: '/ajax/auth/personlist'
            ,page: true
            ,loading: true
            ,cellMinWidth: 80
            ,limit: 20
            ,id: 'groupList'
            ,cols: [[
                {field: 'id', title: '组织号', width: 80, sort: true, fixed: 'left'}
                ,{field: 'name', title: '名字 '}
                ,{field: 'education', title: '学历'}
                ,{field: 'industry', title: '工作行业'}
                ,{fixed: 'right', title: '操作', align: 'center', width: 200, toolbar: '#dothing' }
            ]]
        });






        layui.$("#searchBtn").click(function () {
            var idCard = $('#idCard').val();//获取输入框的值
            var userId = $("#userId").val();



            table.reload('groupList',
                {
                    page:
                        {
                            curr: 1 //重新从第 1 页开始
                        }
                    ,limit:10
                    ,where: { idCard: idCard,
                        userId:userId}//这里传参  向后台
                    ,url: '/ajax/party/admin/serachGroup'//后台做模糊搜索接口路径
                    ,method: 'post',
                });

        });


        // //这个是用于创建点击事件的实例
        // $('#search .layui-btn').on('click', function ()
        // {
        //     var type = $(this).data('type');
        //     active[type] ? active[type].call(this) : '';
        // });
        //搜索






        //监听工具条
        table.on('tool(groupList)', function(obj){
            var data = obj.data;

            if(obj.event === 'detail'){

                $.post('/ajax/auth/getOneAuth',{
                    id:data.id
                },function(result){
                    layer.open({
                        type: 1,
                        area: ['1200px','80%'],
                        title: "ID:" + data.id,
                        offset: '10%',
                        anim: 4,
                        shadeClose: true,
                        content: showDetails(result.data)
                    });



                });

            } else if(obj.event === 'del'){
                layer.confirm('真的删除行么', function(index){
                    $.post("/ajax/party/admin/delGroup",{
                        id:data.id
                    },function(result){
                        console.log(result);
                        if(result.code==0){
                            layer.alert("删除成功！");
                        }
                        obj.del();
                        layer.close(index);
                    });
                });
            }
        });





        form.on('submit(ok)',function (data) {



            $.ajax({
                type:"post",
                url:"/ajax/party/admin/addgroup",
                contentType : 'application/json;charset=utf-8',
                //设置请求头信息
                dataType:"json",
                data:JSON.stringify(data.field),
                success:function (res) {
                    if(res.code==0){
                        layer.alert("OK");
                        // refresh();

                    }
                }
            })

            return false;
        })


    });
</script>




<script type="application/javascript">
    function showDetails(data) {


        var s = '';


        return s;
    }


</script>

<script type="text/html" id="dothing">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>

    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>









</body>
</html>